<template>
	<view class="page" :style="{'min-height':h+'px','padding-top':mt+'px'}">
		<!-- 头部 -->
		<c-nav-bar title="退款详情" bgColor="#007A69" leftIconColor="#ffffff"
			:titleStyle="{'fontSize': '36rpx','fontWeight': 'bold','color': '#ffffff'}"></c-nav-bar>
		<view class="bg"></view>
		<view class="t_top box">
			<text class="title" v-if="orderState==6">退款中</text>
			<text class="title" v-if="orderState==7">已退款</text>
			<image src="https://i.ringzle.com/file/20240521/b22bd2245a874e3e9974852ce55cc2c1.png"></image>
			<view class="tt_text">
				<view>提交订单</view>
				<view>退款审核</view>
				<view v-if="orderState==6">审核中</view>
				<view v-else-if="orderState==7">审核通过</view>				
			</view>
		</view>
		<view class="t_money box">
			<view class="tm_top">
				<view class="tmt_left">退款金额</view>
				<view class="tmt_right">￥<text>{{refundMoney}}</text></view>
			</view>
			<text>扣除手续费 ￥{{refundCharge}}</text>
		</view>
		<view class="t_passenger box">
			<text class="tp_title">乘客信息</text>
			<view v-for="(p,idx) in item.detailDTOList" :key="idx">
				<view class="tp_info">
					<text>{{p.passName}}</text>
					<view>{{personTypeCfg[p.priceType]||''}}</view>
				</view>
				<view class="tp_idcard">{{personCardCfg[p.credentialType]||'证件号'}} {{p.credentialNum}}</view>
			</view>
		</view>
		<view class="t_details box">
			<view class="td_item">
				<text class="tdi_left">退回账户</text>
				<view class="tdi_right">原路返回</view>
			</view>
			<view class="td_item">
				<text class="tdi_left">退款流水号</text>
				<view class="tdi_right">
					<text>{{item.id}}</text>
					<view class="copy" @tap="copyOrderNo">复制</view>
				</view>
			</view>
			<view class="td_item">
				<text class="tdi_left">退款原因</text>
				<view class="tdi_right">{{item.refundReason}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'refundDetails',
		data() {
			return {
				h: uni.getWindowInfo().windowHeight - 60,
				mt: uni.getSystemInfoSync().statusBarHeight + 44,
				titleStyle: {
					fontSize: '36rpx',
					fontWeight: "bold",
					color: "#FFFFFF"
				},
				item: null,
				id: '',
				person: null,
				orderState:'',
				refundMoney:0,
				refundCharge:0
			}
		},
		onLoad(option) {
			if (option.item) this.item = JSON.parse(option.item);
			if (option.id) this.id = option.id;
			if (option.orderState) this.orderState = option.orderState;
			if (option.person){
				this.person = JSON.parse(decodeURIComponent(option.person));
				let temp = JSON.parse(decodeURIComponent(option.person));
				this.refundMoney+=(parseFloat(temp.realRefundFee||temp.refundFee)||0);
				if(temp.isQuitCharge==1) this.refundMoney+=(temp.realRefundCharge||temp.refundCharge);
				this.refundCharge = parseFloat(temp.realFee)-this.refundMoney;
			} 
			this.getDetails();
		},
		methods: {
			copyOrderNo() {
				let that = this;
				// #ifdef H5
				this.$copyText(this.item.id).then(res => {
					this.$showToast('复制成功');
				})
				// #endif
				// #ifdef MP-WEIXIN
				uni.setClipboardData({
					data: this.item.id,
					success(res) {
						that.$showToast('复制成功');
					},
					fail(err) {
						that.$showToast('复制失败');
					}
				})
				// #endif
			},
			getDetails() {
				this.$api.get('/api/travel/getRefundInfo/' + this.id).then(res => {
					if (res.data.code === 0) {
						this.item = res.data.data;
						this.item.detailDTOList = [this.person];
					} else this.$showModal(res.data.msg);
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.page {
		background: #F5F8FA;
		display: flex;
		align-items: center;
		flex-direction: column;
		padding-bottom: 140rpx;

		.bg {
			height: 860rpx;
			position: fixed;
			top: 44px;
			z-index: 1;
			width: 100%;
			background-image: linear-gradient(to bottom, #007A69, #007A69, #F5F8FA);
		}

		.box {
			width: calc(100% - 96rpx);
			background: #FFFFFF;
			border-radius: 16rpx;
			margin-top: 20rpx;
			z-index: 1;
		}

		.t_top {
			display: flex;
			flex-direction: column;
			margin-top: 40rpx;
			width: calc(100% - 48rpx);
			background: transparent;
			padding: 0 24rpx;

			.title {
				font-size: 36rpx;
				font-family: PingFang-SC-Bold, PingFang-SC;
				font-weight: bold;
				color: #FFFFFF;
				text-indent: 30rpx;
			}

			&>image {
				width: calc(100% - 60rpx);
				height: 36rpx;
				margin: 36rpx 30rpx 0;
			}

			.tt_text {
				display: flex;
				align-items: center;
				justify-content: space-around;
				margin-top: 24rpx;
				text-align: center;

				view {
					width: calc(100% / 3);
					font-size: 24rpx;
					font-family: PingFang-SC-Bold, PingFang-SC;
					font-weight: bold;
					color: #FFFFFF;

					&:first-child {
						text-align: left;
					}

					&:last-child {
						text-align: right;
					}
				}
			}
		}

		.t_money {
			padding: 48rpx 24rpx;
			display: flex;
			flex-direction: column;
			margin-top: 40rpx;

			.tm_top {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.tmt_left {
					font-size: 36rpx;
					font-family: PingFang-SC-Bold, PingFang-SC;
					font-weight: bold;
					color: #333333;
				}

				.tmt_right {
					display: flex;
					align-items: center;
					font-size: 24rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #FF4141;

					text {
						font-size: 36rpx;
						font-family: DINAlternate-Bold, DINAlternate;
						font-weight: bold;
						color: #FF4141;
					}
				}
			}

			&>text {
				font-size: 24rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #808080;
				margin-top: 36rpx;
			}
		}

		.t_passenger {
			padding: 40rpx 24rpx;
			display: flex;
			flex-direction: column;

			.tp_title {
				font-size: 36rpx;
				font-family: PingFang-SC-Bold, PingFang-SC;
				font-weight: bold;
				color: #333333;
			}

			.tp_info {
				margin-top: 16rpx;
				display: flex;
				align-items: center;

				&>text {
					font-size: 30rpx;
					font-family: PingFang-SC-Bold, PingFang-SC;
					font-weight: bold;
					color: #333333;
				}

				&>view {
					margin-left: 25rpx;
					width: 88rpx;
					height: 36rpx;
					background: #F5F8FA;
					border-radius: 8rpx;
					line-height: 36rpx;
					text-align: center;
					font-size: 24rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #94A9C8;
				}
			}

			.tp_idcard {
				margin-top: 16rpx;
				font-size: 24rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #666666;
			}
		}

		.t_details {
			padding: 0 24rpx;

			.td_item {
				padding: 31rpx 0;
				border-bottom: 1rpx solid #EFEFEF;
				display: flex;
				align-items: center;
				justify-content: space-between;

				&:last-child {
					border-bottom: none;
				}

				.tdi_left {
					font-size: 28rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #777777;
				}

				.tdi_right {
					font-size: 28rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #333333;
					display: flex;
					align-items: center;

					text {
						font-size: 28rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #333333;
					}

					.copy {
						margin-left: 17rpx;
						width: 78rpx;
						height: 36rpx;
						border-radius: 18rpx;
						border: 1rpx solid #007A69;
						line-height: 36rpx;
						text-align: center;
						font-size: 22rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #007A69;
					}
				}
			}
		}
	}
</style>